﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;

namespace WmsApp.StaticData
{
    /// <summary>
    /// 货物类型的抽象观察者
    /// </summary>
    public abstract class BaseGoodsCodeTypeObserver
    {
        protected Object GoodsCodeTypeLookUpEdit;
        protected string Name;
        protected IGoodsCodeTypeSubject Subject;
        protected Form Form;

        private EventHandler _parentControlClosed;
        public event EventHandler ParentControlClosed
        {
            add
            {
                _parentControlClosed += value;
            }
            remove
            {
                _parentControlClosed -= value;
            }
        }   

        protected BaseGoodsCodeTypeObserver(string name,
            IGoodsCodeTypeSubject goodsCodeTypeSubject,
             Object goodsCodeTypeLookUpEdit,
            Form form)
        {
            this.Form = form;
            this.Name = name;
            this.Subject = goodsCodeTypeSubject;
            this.GoodsCodeTypeLookUpEdit = goodsCodeTypeLookUpEdit;

            form.FormClosing += (object sender, FormClosingEventArgs e)=>
                                    {
                                        if (_parentControlClosed != null)
                                        {
                                            _parentControlClosed(sender, new EventArgs());
                                        }
                                    };
           
        }

        public abstract void UpdateData();
    }
}
